package com.hyz.controller;

import com.hyz.pojo.ResponseResult;
import com.hyz.pojo.assetSecondment.AssetSecondment;
import com.hyz.pojo.assetSecondment.AssetSecondmentResult;
import com.hyz.service.AssetSecondmentService;
import com.hyz.utils.AssetSecondmentUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author HGD
 * @date 2022/10/9 19:08
 */
@Api("信息管理经理")
@RestController
@RequestMapping("/information")
public class InformationController {
    @Autowired
    private AssetSecondmentService asService;
    @Autowired
    private AssetSecondmentUtils asUtils;

    @ApiOperation("信息管理经理获取所有调用申请")
    @PostMapping("/ifGetAssetSecondments")
    public ResponseResult<List<AssetSecondment>> ifGetAssetSecondments() {
        return asUtils.getAssetSecondments(AssetSecondmentResult.CREATE);
    }

    @ApiOperation("信息管理经理审批借用申请")
    @PostMapping("/ifUpdateAssetSecondment")
    public ResponseResult<String> ifUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                          @RequestParam("result") AssetSecondmentResult result) {
        return asUtils.updateAssetSecondment(assetSecondmentId, AssetSecondmentResult.CREATE, result);
    }
}
